<?php
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){

exi($return);
}
if($_RQ['op']=='sendcode'){
	$post=get_postdata();
	$mobile=$post['mobile'];
	$code=rand(1000,9999);
	$_SESSION['smscode']=$code;
	$_SESSION['mobile']=$mobile;
	$content=array('code'=>$code);
	$result=$this->model('notice')->set_sms2($mobile,$content);

	if($result){
		exi('success');
	}else{
		exi('error');
	}

}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	
	if(!$postdata['mobile'] || strlen($postdata['mobile'])!=11){
		exi('请输入6位以上密码','error');
	}
	if(!$postdata['password'] || strlen($postdata['password'])<6){
		exi('请输入6位以上密码','error');
	}
	if($postdata['password']!=$postdata['password2']){
		exi('2次输入密码不一致','error');
	}
	if(!$postdata['code']){
		exi('请输入验证码','error');
	}
	
	if($postdata['code']!=$_SESSION['smscode']){
		exi('验证码错误','error');
	}
	if($postdata['mobile']!=$_SESSION['mobile']){
		exi('手机号码不匹配！','error');
	}
	unset($_SESSION['smscode'],$_SESSION['mobile']);
	$info=pdo_get('core_members',array('mobile'=>$postdata['mobile']));
	if(!$info){
		exi('该手机号未注册','error');
	}
	pdo_update('core_members',array('password'=>encryptPwd(trim($postdata['password']))),array('mobile'=>$postdata['mobile']));
	if($_SESSION['os']=='windows'){
		exi('找回成功','','/member.login/');
	}else{
		exi('找回成功','','goback');
	}
	
}